package com.huage_09;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.huage_09.domain.User;

import java.io.IOException;

public class JsonToJava {
    public static void main(String[] args) throws IOException {

        String json = "{\"name\":\"张三\",\"age\":23,\"gender\":\"男\",\"date\":\"2021-03-17\"}";
        ObjectMapper mapper = new ObjectMapper();
        User user = mapper.readValue(json, User.class);
        System.out.println(user);
        System.out.println(user.getName());
    }
}
